function f  = new_sj_CT(ini_var,delta_i,x2_i,theta2,v_c,cf_salestax_i,tier_i,cat_i,FC_i,mc_i,A1_i,mrks_i,UVT,tariff_i)% function computing counterfactual price equilibrium  
tax=ini_var(1);
cat_t=cat_i.*tax* UVT;

p_nt_i=ini_var(2:end);
p_in=(p_nt_i.*(1+cf_salestax_i+tier_i))+(cat_t./1000);
expmu_cf = expmu(theta2,v_c,x2_i,p_in);
expdelta_cf=exp(delta_i);
s_indiv=ind_shares(expdelta_cf,expmu_cf); 
sj_cf=mean(s_indiv,2);

price1=((mc_i+markup_sim(theta2,v_c,delta_i,s_indiv,A1_i,sj_cf)).*(1+cf_salestax_i+tier_i))+(cat_t./1000);
expmu_cf2 = expmu(theta2,v_c,x2_i,price1);
s_indiv2=ind_shares(expdelta_cf,expmu_cf2); 
sj_cf2=mean(s_indiv2,2);
%sim_i=round(sj_cf2.*mrks_i,0);
sim_i=sj_cf2.*mrks_i;

tf_i=sim_i.*(mc_i./(1+tariff_i)).*(tariff_i);
st_i=sim_i.*((((price1-(cat_t./1000))./(1+cf_salestax_i+tier_i)).*(cf_salestax_i+tier_i))+(cat_t./1000));

fc_i=tf_i+st_i;


nsj=norm(sum(FC_i)*1000-sum(fc_i)*1000);
npj=norm((p_in.*1000)-(price1.*1000));

f=nsj+npj;
%f=nsj;
end